public class PasswordGenerator {
    public static String getPassword(Integer len) {
        Blob blobKey = crypto.generateAesKey(128);
        String key = EncodingUtil.convertToHex(blobKey);
        
        System.debug(key);
        return key.substring(0,len);
    }
    
    public static testMethod void testPG() {
        System.debug(PasswordGenerator.getPassword(8));
    }
}